<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/classes/Object.class.php, $Author:  $ */

/** 
 * Contains common function and Error handling API.
 * @package core
 */
class Object
{
    /** Error messages.
     * @var array
     */
    var $aErrors = array();


    /** Default constructor (empty)
     * @return Common
     */
    function Object() 
    { 

    }

    /** Returns all errors generated by object
     * @return array errors
     */
    function getErrors()
    {
        return $this->aErrors;
    }

    /** Adds an error to object error pool.
     * @param string  $sKey   key of error message
     * @param mixed   $aParm  paramteres of error message
     * @param boolean $bFatal true - fatal error, false (deafult) - recoverable error
     * @return boolean false
     */
    function _addError($sKey, $mParam=array(), $bFatal=false)
    {
        if ($mParam && !is_array($mParam))
            $mParam = array($mParam);

        $sErr = App::format($sKey, $mParam);
        $this->aErrors[] = $sErr;
        if ($bFatal)
        {
            //see trigger_error
            trigger_error(substr($sErr, 0, 1024), E_USER_ERROR);
            exit;
        }
        return false;
    }

    function addErrors($mErrors)
    {
        if (is_array($mErrors))
        {
            foreach($mErrors as $sError)
            {
                $this->aErrors[] = $sError;
            }
        }
        else
        {
            $this->aErrors[] = $mErrors;
        }
    }
}
?>